package com.unionpay.upop.sdk;

import java.io.IOException;
import java.io.InputStream;
import java.util.PropertyResourceBundle;

import org.apache.log4j.Logger;

import com.unionpay.upmp.sdk.conf.UpmpConfig;


public class QuickPayConf {

	static final Logger logger = Logger.getLogger(QuickPayConf.class);

	private static final String CONF_FILE_NAME = "upmp.properties";

	// 版本号
	public final static String version = "1.0.0";

	// 编码方式
	public final static String charset = "UTF-8";

	// 基础网址（请按相应环境切换）

	/* 前台交易测试环境 */
//	private final static String UPOP_BASE_URL = "http://58.246.226.99/UpopWeb/api/";

	/* 前台交易PM环境（准生产环境） */
	private   static String UPOP_BASE_URL = "https://www.epay.lxdns.com/UpopWeb/api/";

	/* 前台交易生产环境 */
	//private final static String UPOP_BASE_URL = "https://unionpaysecure.com/api/";
	
	/* 后台交易测试环境 */
//	private final static String UPOP_BSPAY_BASE_URL = "http://58.246.226.99/UpopWeb/api/";
	
	/* 后台交易PM环境（准生产环境） */
	private   static String UPOP_BSPAY_BASE_URL = "https://www.epay.lxdns.com/UpopWeb/api/";
	
	/* 后台交易生产环境 */
	//private final static String UPOP_BSPAY_BASE_URL = "https://besvr.unionpaysecure.com/api/";
	
	/* 查询交易测试环境 */
//	private final static String UPOP_QUERY_BASE_URL = "http://58.246.226.99/UpopWeb/api/";
	
	/* 查询交易PM环境（准生产环境） */
	private   static String UPOP_QUERY_BASE_URL = "https://www.epay.lxdns.com/UpopWeb/api/";
	
	/* 查询交易生产环境 */
	//private final static String UPOP_QUERY_BASE_URL = "https://query.unionpaysecure.com/api/";

	// 支付网址
	public  static String gateWay = UPOP_BASE_URL + "Pay.action";

	// 后续交易网址
	public   static String backStagegateWay = UPOP_BSPAY_BASE_URL + "BSPay.action";

	// 查询网址
	public   static String queryUrl = UPOP_QUERY_BASE_URL + "Query.action";
	
	// 认证支付2.0网址
	public   static String authPayUrl = UPOP_BASE_URL + "AuthPay.action";
	
	// 发短信网址
	public   static String smsUrl = UPOP_BASE_URL + "Sms.action";

	// 商户代码
	public   static  String merCode = "898111148160112";
//	public final static String merCode = "105550149170027";

	// 商户名称
	public final static String merName = "巴士在线控股";

	public   static String merFrontEndUrl = "http://124.207.86.73:10080/ec/upmpWebPayFront.page";

	public   static String merBackEndUrl = "http://124.207.86.73:10080/ec/upmpWebPayBack.page";

	public static String upop_pay_time_out ;
	
	// 加密方式
	public final static String signType = "MD5";
	public final static String signType_SHA1withRSA = "SHA1withRSA";

	// 商城密匙，需要和银联商户网站上配置的一样
	public    static   String securityKey = "88888888";

	// 签名
	public final static String signature = "signature";
	public final static String signMethod = "signMethod";

	//组装消费请求包
	public final static String[] reqVo = new String[]{
			"version",
            "charset",
            "transType",
            "origQid",
            "merId",
            "merAbbr",
            "acqCode",
            "merCode",
            "commodityUrl",
            "commodityName",
            "commodityUnitPrice",
            "commodityQuantity",
            "commodityDiscount",
            "transferFee",
            "orderNumber",
            "orderAmount",
            "orderCurrency",
            "orderTime",
            "customerIp",
            "customerName",
            "defaultPayType",
            "defaultBankNumber",
            "transTimeout",
            "frontEndUrl",
            "backEndUrl",
            "merReserved"
	};

	public final static String[] notifyVo = new String[]{
            "charset",
            "cupReserved",
            "exchangeDate",
            "exchangeRate",
            "merAbbr",
            "merId",
            "orderAmount",
            "orderCurrency",
            "orderNumber",
            "qid",
            "respCode",
            "respMsg",
            "respTime",
            "settleAmount",
            "settleCurrency",
            "settleDate",
            "traceNumber",
            "traceTime",
            "transType",
            "version"
	};

	public final static String[] queryVo = new String[]{
		"version",
		"charset",
		"transType",
		"merId",
		"orderNumber",
		"orderTime",
		"merReserved"
	};
	
	public final static String[] smsVo = new String[]{
		"version",
		"charset",
		"acqCode",
		"merId",
		"merAbbr",
		"orderNumber",
		"orderAmount",
        "orderCurrency",
		"merReserved"
	};
	static {
		InputStream fis = UpmpConfig.class.getClassLoader().getResourceAsStream(CONF_FILE_NAME);
		try {
			PropertyResourceBundle props = new PropertyResourceBundle(fis);
			upop_pay_time_out = props.getString("upop_pay_time_out");
			merCode  =props.getString("web.mer.id");
			securityKey = props.getString("web.security.key");
			merFrontEndUrl=props.getString("web.mer.front.end.url");
			merBackEndUrl =props.getString("web.mer.back.end.url");
			UPOP_BASE_URL=props.getString("web.upop.buy.base.url");
			UPOP_BSPAY_BASE_URL=props.getString("web.upop.bsbuy.base.url");
			UPOP_QUERY_BASE_URL=props.getString("web.upop.query.base.url");
			gateWay = UPOP_BASE_URL + "Pay.action";                                                   
			 backStagegateWay = UPOP_BSPAY_BASE_URL + "BSPay.action";          
			 queryUrl = UPOP_QUERY_BASE_URL + "Query.action";                              
		} catch (IOException e) {
			logger.error(e.getMessage(), e);
			e.printStackTrace();
		}
	}
	
	public static void main(String[] args){
		System.out.println(gateWay);
		System.out.println(UPOP_BSPAY_BASE_URL);
		System.out.println(UPOP_QUERY_BASE_URL);
	}
}
